#ifndef XKIT_COLLECTIONS_LIST_H
#define XKIT_COLLECTIONS_LIST_H

#include "losu.h"
#include "platform/platform.h"
#include "../ref.h"
#include "../xkit.h"

#include <stdbool.h>
#include <string.h>

typedef struct VectorHeader {
    Reference *ref;
    losu_object *val;
    size_t realLength;
    size_t curIndex;
} VectorHeader;

#define DEFAULT_LIST_LENGTH 8

losu_extern_t VectorHeader *VectorInit(losu_vm_t vm);
losu_extern_t void VectorFree(losu_vm_t vm, VectorHeader *p);
losu_extern_t void VectorReserve(losu_vm_t vm, VectorHeader *p, size_t expectSize);
losu_extern_t void VectorAppend(losu_vm_t vm, VectorHeader *p, losu_object_t o);
losu_extern_t bool VectorPop(losu_vm_t vm, VectorHeader *p, size_t index, losu_object_t target);
losu_extern_t bool VecotrInsert(losu_vm_t vm, VectorHeader *p, size_t index, losu_object_t o);
losu_extern_t bool VecotrReplace(losu_vm_t vm, VectorHeader *p, size_t index, losu_object_t o);
losu_extern_t void VectorExtend(losu_vm_t vm, VectorHeader *p, VectorHeader *other);
losu_extern_t bool VectorGet(losu_vm_t vm, VectorHeader *p, size_t index, losu_object_t target);
losu_extern_t void VectorClear(losu_vm_t vm, VectorHeader *p);
losu_extern_t void VectorTrim(losu_vm_t vm, VectorHeader *p);
losu_extern_t VectorHeader *VectorSlice(losu_vm_t vm, VectorHeader *p, size_t start, size_t end);

#endif
